package com.chenfan.mcn.dao;

import com.chenfan.common.extension.mybatisplus.enhanced.EnhancedBaseMapper;
import com.chenfan.mcn.model.PlatformDiscountRange;
import com.chenfan.mcn.model.vo.PlatformDiscountRangeVO;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 优惠价格梯度 Mapper 接口
 * </p>
 *
 * @author lizhejin
 * @since 2021-01-07
 */
public interface PlatformDiscountRangeMapper extends EnhancedBaseMapper<PlatformDiscountRange> {

    /**
     * 获取对应折扣审批单的优惠价格
     *
     * @param discountId 折扣审批单id
     * @return List
     */
    List<PlatformDiscountRangeVO> selectByDiscountId(Long discountId);

    /**
     * 查询匹配的平台、商务确认金额累计的返点比例
     *
     * @param platformId
     * @param discountId
     * @param businessYearAmount
     * @return BigDecimal
     */
    BigDecimal getMatchedRate(@Param("discountId") Long discountId, @Param("platformId") String platformId, @Param("businessYearAmount") BigDecimal businessYearAmount);

    /**
     * 通过累计金额，匹配优惠梯度，得到的对应返点比例。
     *
     * @param discountId        {@link Long}
     * @param accumulatedAmount {@link BigDecimal}
     * @return {@link BigDecimal}
     */
    BigDecimal getRebateRatio(Long discountId, BigDecimal accumulatedAmount);

    /**
     * 根据累计金额获取对应折扣审批单的优惠价格
     *
     * @param discountId        {@link Long}
     * @param accumulatedAmount {@link BigDecimal}
     * @return List
     */
    PlatformDiscountRangeVO getPreferentialGradient(Long discountId, BigDecimal accumulatedAmount);

    /**
     * 获取对应折扣审批单的优惠价格(年度返点审批单)
     *
     * @param discountId 折扣审批单id
     * @return List
     */
    List<PlatformDiscountRangeVO> getByDiscountId(Long discountId);
}
